#include<stdio.h>

int isPalindromicString(int n)
{
    int ints[10];
    int i;
    for (i = 0; n>=1; i++)
    {
        ints[i] = n%10;
        n = n/10;
    }
    
    for (int j = 0; j < i/2; j++)
    {
        if (ints[j] != ints[i-j-1])
        {
            return 0;        
        }
        
    }
    return 1;
    
}

int main(void)
{
    int n;
    while (scanf("%d",&n) != EOF)
    {
        for (int i = n+1;; i++)
        {
            if (isPalindromicString(i))
            {
                printf("%d\n",i);
                break;
            }
            
        }
        
    }
    
}
